package com.angola.sms.component.dialog

import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.*
import com.angola.sms.R

class LoadingDialogipetrpide(context: Context) : Dialog(context) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        setContentView(R.layout.dialog_loading)

        window?.apply {
            setBackgroundDrawable(ColorDrawable(0))
            addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
            val layoutParams = attributes
            layoutParams.dimAmount = 0.4f
            layoutParams.gravity = Gravity.CENTER
            attributes = layoutParams
        }

        setCanceledOnTouchOutside(false)
    }

    override fun onStart() {
        super.onStart()


    }

    fun showDialogipetrpide(context: Context) {
        if (context is Activity) {
            if (context.isFinishing) {
                return
            }
        }
        if (isShowing) return
        show()
    }

    fun dismissDialogipetrpide() {
        dismiss()
    }
}